package com.dayuanit.dy15.lesson20.demo2;

import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        //Java集合  List Set queue   Map

        String[] names = new String[2];
        names[0] = "tom";
        names[1] = "jack";
//        names[2] = "xx";//error 数组越界

        ArrayList arrayList = new ArrayList();
        arrayList.add("tom");
        arrayList.add("jack");
        arrayList.add("xxx");

        for (int i=0; i<arrayList.size(); i++) {
            System.out.println(arrayList.get(i));
        }

        arrayList.set(0, "tom2");

        System.out.println("------------");

        System.out.println(arrayList.get(0));


        arrayList.remove(1);
//        arrayList.remove("tom");

        System.out.println("------------");

        for (int i=0; i<arrayList.size(); i++) {
            System.out.println(arrayList.get(i));
        }

//        Object object = arrayList.get(3);
//        System.out.println(object);


    }
}
